<?php namespace App\Services;

use App\Facades\Infra\ComplaintManager;

class ComplaintService{
	public function createComplaint($data){
		ComplaintManager::createComplaint($this->formatData($data));
	}

	public function getComplaints($conditions){
		return ComplaintManager::getComplaints($this->formatConditions($conditions),true)->orderBy('created_at','desc')->paginate(15);
	}

	public function getComplaint($conditions){
		return ComplaintManager::getComplaints($this->formatConditions($conditions));
	}

	public function updateComplaint($data){
		$conditions['id'] = $data['id'];

		ComplaintManager::updateComplaint($this->formatConditions($conditions),$data);
	}

	public function deleteComplaint($conditions){
		ComplaintManager::deleteComplaint($conditions);
	}

	private function formatData($data){
		$data['hotel_id'] = \Auth::user()->id;

		return $data;
	}

	private function formatConditions($conditions){
		$conditions['hotel_id'] = \Auth::user()->id;

		return $conditions;
	}
}